<div class="bjui-pageHeader">
    <form id="pagerForm" data-toggle="ajaxsearch" action="${request.getContextPath()}/ProcessInventory/processInventory" method="post">
        <div class="bjui-searchBar">
            <g:hiddenField name="SYS_QUERY_NAME" value="processInventory" />
            <g:hiddenField name="EXPORT_CONTENT_NAME" value="Excel" />
            <label>批次号：</label>
            <input type="text" name="lotId" value="${lotId}" size="16" placeholder="批次号"/>&nbsp;
            <label>日期：</label>
            <input type="text" name="startTime" value="${startTime}" data-pattern="yyyy-MM-dd"
                   data-toggle="datepicker" size="11" placeholder="开始日期">
            <input type="text" name="endTime" value="${endTime}" data-pattern="yyyy-MM-dd"
                   data-toggle="datepicker" size="11" placeholder="结束日期">&nbsp;
            <label>物料编码：</label>
            <input type="text" name="partName" value="${partName}" size="16" placeholder="物料编码"/>&nbsp;
            <label>工序名称：</label>
            <input type="text" name="stepDesc" value="${stepDesc}" size="16" placeholder="工序名称"/>&nbsp;
            <label>状态：</label>
            %{--<input type="text" name="zt" value="${zt}" size="10" placeholder="状态"/>--}%
            <g:select name="zt" from="${wipStateList}" data-toggle="selectpicker" data-live-search="true" data-width="120"
                      optionKey="STATE" optionValue="STATE" value="${zt}" noSelection="['':'-- All --']" />&nbsp;
            <br /><br />
            <button type="submit" class="btn-default" data-icon="search">查询</button>&nbsp;
            <button type="button" class="btn-blue" onclick="javascript:bjuiExportExl('#pagerForm','${request.getContextPath()}/BadProcessAnalysis/exportExcel')" 
                    data-icon="file-excel-o" title="导出Excel">导出</button>
        </div>
    </form>
</div>

<div class="bjui-pageContent tableContent">
    <g:if test="${processInventory.size() > 0}">
        <table id="lapEndByBatch" data-toggle="tablefixed" data-width="100%" data-nowrap="true">
            <thead>
            <tr id="t1">
                <g:each in="${tableHeadList}" status="j" var="headInstance">
                    <g:if test="${headInstance!='RN'}">
                        <th><g:message code="${headInstance}" default="${headInstance}"/></th>
                    </g:if>
                </g:each>
            </tr>
            </thead>
            <tbody>
            <g:if test="${processInventory.size()>0}">
                    <g:each in="${processInventory}" status="i" var="dataInstance">
                        <tr>
                        <g:each in="${tableHeadList}" status="j" var="headInstance">
                            <g:if test="${headInstance=='ZZSL'}">
                                <td name="ZZSL${i+1}">
                                    ${dataInstance["${headInstance}"] }
                                </td>
                            </g:if>
                            <g:elseif test="${headInstance=='SPSL'}">
                                <td name="SPSL${i+1}">
                                    ${dataInstance["${headInstance}"] }
                                </td>
                            </g:elseif>
                            <g:elseif test="${headInstance=='差异'}">
                                <td name="CY${i+1}">
                                    ${dataInstance["${headInstance}"] }
                                </td>
                            </g:elseif>
                            <g:elseif test="${headInstance!='RN'}">
                                <td>${dataInstance["${headInstance}"]}</td>
                            </g:elseif>
                        </g:each>
                    </tr>
                </g:each>
                <tr>
                    <td colspan="6">小计</td>
                    <td id="ZZSL"></td>
                    <td id="SPSL"></td>
                    <td id="CY"></td>
                </tr>
                <tr>
                    <td colspan="6">合计</td>
                    <td>${processInventorySumQty[0].SUM_ZZSL_QTY}</td>
                    <td>${processInventorySumQty[0].SUM_SPSL_QTY}</td>
                    <td>${processInventorySumQty[0].SUM_CY_QTY}</td>
                </tr>

            </g:if>
            </tbody>
        </table>
    </g:if>
    <g:else>
        <g:render template="../template/emptyPanel" />
    </g:else>
</div>
<g:render template="../template/pagination" />

<script>
    $(function(){
        var progressN=0
        for(var i=1;i<=${processInventory.size()};i++){
            var progressNo='ZZSL'+i
            var progressNor = $("td[name='"+progressNo+"']").text()==''?0:parseInt($("td[name='"+progressNo+"']").text())
            if(isNaN(progressNor)){
                progressNor=0
            }
            progressN+=progressNor
        }
        $("#ZZSL").html(progressN);

        var progressN1=0
        for(var i=1;i<=${processInventory.size()};i++){
            var progressNo1='SPSL'+i
            var progressNor1=parseInt($("td[name='"+progressNo1+"']").text());
            if(isNaN(progressNor1)){
                progressNor1=0
            }
            progressN1+=progressNor1
        }
        progressN1 = isNaN(parseInt(progressN1))?0:progressN1
        $("#SPSL").html(progressN1);

        var progressN2=0
        for(var i=1;i<=${processInventory.size()};i++){
            var progressNo2='CY'+i
            var progressNor2=parseInt($("td[name='"+progressNo2+"']").text());
            if(isNaN(progressNor2)){
                progressNor2=0
            }
            progressN2+=progressNor2
        }
        progressN2 = isNaN(parseInt(progressN2))?0:progressN2
        $("#CY").html(progressN2);
    })
</script>


